/**

* @author Jeremy Wischusen <cortex@visualflowdesigns.com>

* This class allows for a delay before starting the animation.

*/

import mx.transitions.Tween;

import mx.utils.Delegate;

class com.vfd.animation.tweens.DelayedTween extends Tween {

	/*

	Holds the number of seconds to wait before starting the animation. 

	*/

	private var _delay:Number = 0;

	/*

	Instance variable holding a reference to the start function of the Tween class. 

	This is needed due to scoping issues when using setTimeout. 

	*/

	private var superStart:Function;

	public function DelayedTween(object, property, easingFunction, start, end, duration, useSeconds, delay) {

		this.delay = delay;

		/*Use the Delegate class to create a reference back to the tween start function 

		that can be used with setTimeout. */

		this.superStart = Delegate.create(super, super.start);

		super(object,property,easingFunction,start,end,duration,useSeconds);

	}

	/*Override the default start function so that the delay can be applied.*/

	public function start() {

		if (this._delay>0) {

			_global.setTimeout(this.superStart,this._delay);

		} else {

			super.start();

		}

	}

	/*Setter function for delay attribute*/

	public function set delay(seconds:Number) {

		this._delay = Math.abs(seconds*1000);

	}

}